<extend name="Common:common" />
<block name="cssjs">
    <link rel="stylesheet" href="__PUBLIC__/js/uploadify/uploadify.css">
    <script type="text/javascript" src="__PUBLIC__/js/uploadify/jquery.uploadify.min.js"></script>
    <style>
        .uploadify{display:inline-block;}
        .uploadify-button{border:none; border-radius:5px; margin-top:8px;}
        table.add_tab tr td span.uploadify-button-text{color: #FFF; margin:0;}
    </style>
</block>
<block name="body">
<body>
    <!--面包屑导航 开始-->
    <div class="crumb_warp">
        <a href="__MODULE__/Index/info">首页</a> &raquo; <a href="__URL__/index">首页轮播管理</a> &raquo; 添加&nbsp;&nbsp;<a href="__URL__/add"><i class="fa fa-refresh"></i></a>
    </div>
    <!--面包屑导航 结束-->

    <div class="result_wrap">
        <form method="post" id="dataSet" onsubmit="return present();">
            <table class="add_tab">
                <tbody>
                <tr> 
                    <th  width="120">图片：</th>
                    <td>
                        <input type="file" multiple="true" id="file_upload">
                        <img style="display:none;" id="upload_img" src="" width="600">
                    </td>
                    <input id="upload_img_thumb" name="banner_img" type="hidden" value="" multiple="true" />
                </tr>
                <tr>
                    <th>链接：</th>
                    <td>
                        <input type="text" name="banner_href"><span>点击图片之后跳转的地址, 默认为空</span>
                    </td>
                </tr>
                <tr>
                    <th>排序：</th>
                    <td>
                        <input type="text" name="banner_sort" value="10"><span>数值越小, 排序越靠前, 默认值为10</span>
                    </td>
                </tr>
                <tr>
                    <th></th>
                    <td>
                        <input type="submit" value="提交" class="btn-blue">
                        <input type="button" class="back btn-blue" onclick="history.go(-1)" value="返回">
                    </td>
                </tr>
                </tbody>
            </table>
        </form>
    </div>
</body>
<script type="text/javascript">
    //uploadify异步上传图片
    $(function() {
        $("#file_upload").uploadify({
            'swf'               : "__PUBLIC__/js/uploadify/uploadify.swf",
            'uploader'          : "__MODULE__/Upload/uploadImage",
            'buttonText'        : '上传',
            'fileTypeDesc'      : 'Image Files',
            'fileTypeExts'      : '*.gif; *.jpg; *.png; *.jpeg',
            'fileObjName'       : 'file',
            'width'             : 60,
            'onUploadSuccess'   : function(file,data,response) {
            if(response) {
                var data = JSON.parse(data); //由JSON字符串转换为JSON对象
                if(data.code == '201') {
                    dialog.error(data.msg);
                } else {
                    $('#' + file.id).find('.data').html(' 上传完毕');
                    $("#upload_img").attr("src","__ROOT__/"+data.file);
                    $("#upload_img_thumb").attr('value',data.file);
                    $("#upload_img").show();
                }
            }else{
                dialog.error('上传失败!');
            }
        },
        });
    });

    //数据提交
    function present() {
        dialog.presentForm("__URL__/addData", "__URL__/index");
        return false;
    }
</script>
</block>